import java.util.Comparator;
import java.util.TreeSet;

public class Demo6 {
    public static void main(String[] args) {
        TreeSet <Person> personTreeSet=new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                int n1=o1.getAge()-o2.getAge();
                int n2=o2.getName().compareTo(o2.getName());
                return n1==0?n2:n1;
            }
        });

        Person p1=new Person("蒋恬1",200);
        Person p2=new Person("蒋恬2",201);
        Person p3=new Person("蒋恬3",203);

        personTreeSet.add(p1);
        personTreeSet.add(p2);
        personTreeSet.add(p3);
    }
}
